package com.wang.wemedia.controller.v1;

import com.wang.common.model.dto.ResponseResult;
import com.wang.wemedia.api.model.dto.AuthDto;
import com.wang.wemedia.api.model.dto.NewsAuthDto;
import com.wang.wemedia.api.model.dto.WmNewsDto;
import com.wang.wemedia.api.model.dto.WmNewsPageReqDto;
import com.wang.wemedia.service.WmNewsService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * 自媒体图文信息接口
 *
 * @author: wangning
 * @date: 2024/1/12 10:29
 */
@RestController
@RequestMapping("/api/v1/news")
@RequiredArgsConstructor
public class WmNewsController {

    private final WmNewsService wmNewsService;

    /**
     * 审核通过
     *
     * @return responseResult
     */
    @PostMapping("/auth_pass")
    public ResponseResult authPass(@RequestBody NewsAuthDto dto){
        return wmNewsService.authPass(dto);
    }

    /**
     * 审核不通过
     *
     * @return responseResult
     */
    @PostMapping("/auth_fail")
    public ResponseResult authFail(@RequestBody NewsAuthDto dto){
        return wmNewsService.authPass(dto);
    }

    /**
     * 详情自媒体图文信息
     *
     * @param id 主键
     * @return
     */
    @GetMapping("one_vo/{id}")
    public ResponseResult oneVO(@PathVariable Integer id){
        return wmNewsService.oneVO(id);
    }

    /**
     * 条件查询自媒体图文信息
     *
     * @param dto 查询条件
     * @return List<WmNews>
     */
    @PostMapping("/list")
    public ResponseResult findAll(@RequestBody WmNewsPageReqDto dto){
        return  wmNewsService.findAll(dto);
    }

    /**
     * 审核分页
     *
     * @param dto
     * @return
     */
    @PostMapping("/list_vo")
    public ResponseResult listVO(@RequestBody AuthDto dto){
        return wmNewsService.listVO(dto);
    }

    /**
     * 发布文章
     *
     * @param dto
     * @return
     */
    @PostMapping("/submit")
    public ResponseResult submitNews(@RequestBody WmNewsDto dto){
        return wmNewsService.submitNews(dto);
    }

}
